package com.smart.consumer.controller;

import com.smart.consumer.common.reqeust.UserRequestParams;
import com.smart.consumer.common.response.ResponseVo;
import com.smart.consumer.common.vo.UserVo;
import com.smart.consumer.feign.UserFeignApi;
import com.smart.consumer.service.TestService;
import lombok.extern.slf4j.Slf4j;
import org.apache.catalina.User;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@Slf4j
public class FeignConsumerController {
    @Resource
    TestService testService;

    @GetMapping("/test")
    public ResponseVo<String> test() {
        return testService.test();
    }


    @GetMapping("/list/")
    public ResponseVo<UserVo> list(int page, int size) {
        return testService.list(page, size);
    }

    @PostMapping("/register")
    public ResponseVo<UserVo> register(@RequestBody UserRequestParams userRequestParams) {
        return testService.register(userRequestParams);
    }
//    ?uid=1
//    detail/1

    @GetMapping("/detail")
    public ResponseVo<UserVo> detail(@RequestParam Integer uid) {
        return testService.detail(uid);
    }

    @Resource
    UserFeignApi userFeignApi;

    @GetMapping("/test1")
    public ResponseVo<Integer> test1() {
        return userFeignApi.test();
    }
}
